package org.duiduo.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 邮箱工具类
 *
 * @author 夜泷noga
 */
public class MailUtil {

    /**
     * 判断输入的邮箱格式是否正确
     *
     * @param str 输入的邮箱地址
     * @return 返回邮箱地址是否正确
     */
    public static boolean isMail(String str) {
        boolean flag = false;
        String regEx1 = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
        Pattern p;
        Matcher m;
        p = Pattern.compile(regEx1);
        m = p.matcher(str);
        if (m.matches()) {
            flag = true;
        }
        return flag;
    }
}
